package csu.web.mypetstore.controller;

import org.springframework.web.bind.annotation.RestController;
import csu.web.mypetstore.service.ItemService;
import csu.web.mypetstore.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@CrossOrigin
public class ItemController {

    @Autowired
    private ItemService itemService;
    @GetMapping("products/{productId}/items")
    public Result getItems(@PathVariable("productId") String productId) {
        return  itemService.getItemList(productId);
    }
    @GetMapping("products/{productId}/items/{itemId}")
    public Result getItemById(@PathVariable("itemId") String itemId) {
            return itemService.getItemInfo(itemId);
    }
}